package de.hfu.mdsd.modisco;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.gmt.modisco.java.generation.files.GenerateJavaExtended;

public class GenerateJavaCode {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		// Initialize XMI factory to register XMI resources
		XMIResourceFactoryImpl xmiResourceFactoryImpl = new XMIResourceFactoryImpl() {
			public Resource createResource(URI uri) {
				XMIResource xmiResource = new XMIResourceImpl(uri);
				return xmiResource;
			}
		};
		Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(
				"xmi", xmiResourceFactoryImpl);

		
		// Generate java source code from a normal java xmi model
		GenerateJavaExtended javaGenerator = new GenerateJavaExtended(
				URI.createFileURI("PPSWEB_java.xmi"), new File("myOutputFolderJava"),
				new ArrayList<Object>());
		javaGenerator.doGenerate(null);
		
	}
}
